package io.elegant

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.ScrollView
class ElegantScrollView(context: Context, attrs: AttributeSet): ScrollView(context, attrs) {
    var isScrollable = true
    override fun onTouchEvent(ev: MotionEvent): Boolean {
        return when (ev.action) {
            MotionEvent.ACTION_DOWN -> {
                if (isScrollable)
                    super.onTouchEvent(ev) else isScrollable
            }
            else -> super.onTouchEvent(ev)
        }
    }
    override fun onInterceptTouchEvent(ev: MotionEvent) = if (!isScrollable) false else super.onInterceptTouchEvent(ev)
}